<!DOCTYPE html>
<html>

  <head>
    <meta charset="UTF-8">
    <title>secret key add</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/static/super_cmdb/css/font.css">
    <link rel="stylesheet" href="/static/super_cmdb/css/xadmin.css">

  </head>

  <body>
    <div class="x-body">
        <form class="layui-form">
          <div class="layui-form-item">
              <label for="setting_name" class="layui-form-label">
                  <span class="x-red">*</span>配置名称
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="setting_name" name="setting_name" required="" lay-verify="required"
                  autocomplete="off"  class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="server_id" class="layui-form-label">
                  <span class="x-red">*</span>server_id
              </label>
              <div class="layui-input-inline">
                  <input type="text" id="server_id" name="server_id" required="" lay-verify="required"
                  autocomplete="off"  class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label for="purpose_id" class="layui-form-label">
                  <span class="x-red">*</span>用途
              </label>
              <div class="layui-input-inline">
                  <select id="purpose_id" name="purpose_id">
                      <option value="1">游戏配置模板</option>
                      <option value="2">公共分区配置</option>
                  </select>
              </div>
          </div>
          <div style="padding-bottom: 10px;padding-left: 100px;">
            <span STYLE="color: red;">【游戏模板】中需要由平台生成的端口字段用小写的 xxxport / xxx_port / port / portxxx / port_xxx，其他固定端口字段请用大写的 PORT，代码中只对包含小写port的字段进行生成端口号</span>
          </div>
          <div style="padding-bottom: 10px;padding-left: 100px;">
            <span STYLE="color: red;">【注意】请指定起始端口号，每个服的端口会累加30，如：1服 2服 3服 的端口将会分别是 10030 10060 10090</span>
          </div>
          <div style="padding-bottom: 10px;padding-left: 100px;">
            <span STYLE="color: red;">【游戏模板】中固定的端口用大写的 xxxPORT / xxx_PORT / PORT / PORTxxx / PORT_xxx，包含大写的 PORT，如mangodb的端口，PORT: 27017</span>
          </div>
          <div style="padding-bottom: 10px;padding-left: 100px;">
            <span STYLE="color: red;">【游戏模板】中 服id字段指定为 server_id; 服中需要指定本服的域名的字段指定为 domain; 其他字段可以任意自定义</span>
          </div>


          <div class="layui-form-item">
              <label for="setting_content" class="layui-form-label">
                  <span class="x-red">*</span>配置内容
              </label>
              <div class="layui-input-inline">
                  <textarea id="setting_content" name="setting_content" style="margin: 0px;width: 765px;height: 318px;font-size: 14px;font-weight: bold;color: royalblue;line-height: 20px;">
必须为json格式，内容字段可任意自定义，公共分区配置按照以下格式
{
    "跨服类型1": {
        "跨服server_id": {
            "cross_server_cfg":{},  #内容为跨服的配置信息
            "game_server_id": [],   #内容为连接该跨服的游戏服列表
            "remarks": "跨服类型1名称"
        }
    },
    "跨服类型2": {
        "跨服server_id": {
            "cross_server_cfg": {}, #内容为跨服的配置信息
            "game_server_id": [],   #内容为连接该跨服的游戏服列表
            "remarks": "跨服类型2名称"
        }
    }
}
                  </textarea>
              </div>
          </div>

          <div class="layui-form-item">
              <label for="L_repass" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  添加
              </button>
          </div>
      </form>
    </div>
    <script type="text/javascript" src="/static/super_cmdb/js/jquery.min.js"></script>
    <script type="text/javascript" src="/static/super_cmdb/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/static/super_cmdb/js/xadmin.js"></script>
    <script type="text/javascript" src="/static/super_cmdb/js/jquery.cookie.js"></script>
        <script>

        $(function () {
            $.ajaxSetup({
                beforeSend:function (xhr,settings) {
                    xhr.setRequestHeader("X-CSRFtoken",$.cookie("csrftoken"));
                }
            })
        });

      layui.use(['form','layer'], function(){
          $ = layui.jquery;
        var form = layui.form
        ,layer = layui.layer;

        //监听提交
        form.on('submit(add)', function(data){
          console.log(data);
          //发异步，把数据提交给php
            $.ajax({
                url: "/configcenter/conf_setting_add/",
                type: "POST",
                //data: $('#layui-form').serialize(),
                data: {
                    "setting_name":$("#setting_name").val(),
                    "server_id":$("#server_id").val(),
                    "purpose_id": $("#purpose_id").val(),
                    "setting_content": $("#setting_content").val()
                    },
                success: function (data) {
                    if (data.code == 0) {
                      layer.alert(data.msg, {icon: 6});
                    } else {
                      layer.alert(data.msg, {icon: 7});
                    }
                }
            });
            return false;
        });
      });

  </script>
  </body>

</html>
